import java.util.*;

class Gen_LU_request extends Proc{
	Random slump = new Random();
	public Proc sendTo;
	
	public void TreatSignal(Signal x){
		switch (x.signalType){
			case G.READY:{
				SignalList.SendSignal(G.ARRIVAL_LU_REQUEST, sendTo, G.time);
				double arrivalTime;
				if(!G.RETRIAL_ALG) {
					arrivalTime = G.time - G.LU_REQUEST_ARRIVAL_TIME * Math.log(slump.nextDouble());					
				}
				else {
					if(G.time <= 2 || G.time >= 3 ) {
						//next Location Update request
						arrivalTime = G.time - G.ARRIVAL_TIME_RETRIAL_1 * Math.log(slump.nextDouble());	
					}
					else {
						arrivalTime = G.time - G.ARRIVAL_TIME_RETRIAL_2 * Math.log(slump.nextDouble());	
					}
				}
				//next Location Update request
				SignalList.SendSignal(G.READY, x.destination, 
						arrivalTime);
			}break;
		}
	}
}